package softtech.apps.callblocker.model;

import java.io.Serializable;

import android.content.ContentValues;
import android.database.Cursor;
import android.util.Log;

public class BlackListItem implements Serializable{

	public  static final String TABLE_NAME = "BlackListItem";
	
	private int id;
	public static final String ID = "id";
	
	private String phoneNumber;
	public static final String PHONE_NUMBER = "phoneNumber";

	private String name;
	public static final String NAME = "name";

	private int mode;
	public static final String MODE = "mode";
	
	public BlackListItem() {
		super();
		// TODO Auto-generated constructor stub
	}

	public BlackListItem(int id, String phoneNumber, String name, int mode) {
		super();
		this.id = id;
		this.phoneNumber = phoneNumber;
		this.name = name;
		this.mode = mode;
	}
	public BlackListItem(String phoneNumber, String name, int mode) {
		super();
		this.phoneNumber = phoneNumber;
		this.name = name;
		this.mode = mode;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getMode() {
		return mode;
	}

	public void setMode(int mode) {
		this.mode = mode;
	}

	public ContentValues getValuesSetting() {
		// TODO Auto-generated method stub
		ContentValues values = new ContentValues();
		values.put(PHONE_NUMBER, this.getPhoneNumber());
		values.put(NAME, this.getName());
		values.put(MODE, this.getMode());
		
		return values;
	}
	
	public static BlackListItem setValueFromCursor(Cursor c){
		
		BlackListItem item = new BlackListItem();
		try{
			item.setId(Integer.parseInt( c.getString(c.getColumnIndex(ID)).trim()));
		}catch(Exception e){
			
		}
		if(c.getColumnIndex(PHONE_NUMBER)>0){
			item.setPhoneNumber(c.getString(c.getColumnIndex(PHONE_NUMBER)));
		}
		if(c.getColumnIndex(NAME)>0){
			item.setName(c.getString(c.getColumnIndex(NAME)));
		}
		if(c.getColumnIndex(MODE)>0){
			item.setMode(c.getInt(c.getColumnIndex(MODE)));
		}
		return item;
	}
	public String toString(){
		return "BlackListItem: " + this.getId() + " " + this.getPhoneNumber() + " "+
				this.getName() + " " + this.getMode();
	}
}
